from django.db import models
from WordBook.models import WordBook


# Create your models here.
class Word(models.Model):
    # 单词ID,并设置为主键
    word_id = models.IntegerField(primary_key=True)
    # 单词值
    word_value = models.CharField(max_length=128)
    # 中文释义
    zh_meaning = models.CharField(max_length=128)
    # 例句
    sentence = models.CharField(max_length=1024)
    # 音标
    phonetic = models.CharField(max_length=128)
    # 与单词本建立多对多关系
    wordbook = models.ManyToManyField(WordBook)

    # 在后台显示单词详细信息
    def __str__(self):
        return "单词ID:{}, 单词:{}".format(self.word_id, self.word_value)

    # 指定表名
    class Meta:
        # db_table = '单词'
        # 指定后台名称
        verbose_name = '单词'
